package cn.yuanqiao.web.controller.manage;

import cn.yuanqiao.common.core.domain.TreeSelect;
import cn.yuanqiao.common.utils.poi.ExcelUtil;
import cn.yuanqiao.common.core.controller.BaseController;
import cn.yuanqiao.common.core.domain.AjaxResult;
import cn.yuanqiao.common.core.page.TableDataInfo;
import cn.yuanqiao.common.annotation.Log;
import cn.yuanqiao.common.enums.BusinessType;
import cn.yuanqiao.manage.domain.ManageSys;
import cn.yuanqiao.manage.service.IManageSysService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 租户三员Controller
 * 
 * @author yuanqiao
 * @date 2023-06-09
 */
@RestController
@RequestMapping("/manage/sys")
public class ManageSysController extends BaseController
{
    @Autowired
    private IManageSysService manageSysService;

    /**
     * 查询租户三员列表
     */
    //@RequiresPermissionsmissions("manage:sys:list")
    @Log(title = "查询租户三员列表", businessType = BusinessType.SELECT)
    @GetMapping("/list")
    public TableDataInfo list(ManageSys manageSys)
    {
        startPage();
        List<ManageSys> list = manageSysService.selectManageSysList(manageSys);
        return getDataTable(list);
    }

    /**
     * 导出租户三员列表
     */
    //@RequiresPermissionsmissions("manage:sys:export")
    //@Log(title = "租户三员", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ManageSys manageSys)
    {
        List<ManageSys> list = manageSysService.selectManageSysList(manageSys);
        ExcelUtil<ManageSys> util = new ExcelUtil<ManageSys>(ManageSys.class);
        util.exportExcel(response, list, "租户三员数据");
    }

    /**
     * 获取租户三员详细信息
     */
    //@RequiresPermissionsmissions("manage:sys:query")
    @Log(title = "获取租户三员详细信息", businessType = BusinessType.SELECT)
    @GetMapping(value = "/{ID}")
    public AjaxResult getInfo(@PathVariable("ID") String ID)
    {
        return success(manageSysService.selectManageSysByID(ID));
    }

    /**
     * 新增租户三员
     */
    //@RequiresPermissionsmissions("manage:sys:add")
    //@Log(title = "租户三员", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ManageSys manageSys)
    {
        return toAjax(manageSysService.insertManageSys(manageSys));
    }

    /**
     * 修改租户三员
     */
    //@RequiresPermissionsmissions("manage:sys:edit")
    @Log(title = "修改租户三员", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ManageSys manageSys)
    {
        return toAjax(manageSysService.updateManageSys(manageSys));
    }

    /**
     * 删除租户三员
     */
    //@RequiresPermissionsmissions("manage:sys:remove")
    @Log(title = "租户三员", businessType = BusinessType.DELETE)
	@DeleteMapping("/{IDs}")
    public AjaxResult remove(@PathVariable String[] IDs)
    {
        return toAjax(manageSysService.deleteManageSysByIDs(IDs));
    }

    /**
     * 获取部门树列表
     */
    //@RequiresPermissionsmissions("manage:sys:tree")
    @Log(title = "获取租户信息树", businessType = BusinessType.SELECT)
    @GetMapping("/tenantTree")
    public AjaxResult deptTree()
    {
        List<TreeSelect> treeSelects = manageSysService.selectTenantTreeList();
        return success(treeSelects);
    }
}
